<template>
  <div class="MarketJump">
    <img class="imgBg" src="../assets/image/shichangBg.jpg" alt="" />
    <div class="shichang">
      <div class="one">
        <img class="imgA" src="../assets/image/shichangLogo.png" alt="" />
      </div>
      <div class="two">
        <!-- <img
          class="imgB"
          src="../assets/image/shichangBtn.png"
          alt=""
          @click="isJump"
        /> -->
        <button id="btn" @click="isJump">免费下载</button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  methods: {
    isJump() {
      let sUserAgent = navigator.userAgent.toLowerCase();

      var isIphone = sUserAgent.match(/iphone/i) == "iphone";
      var vx = sUserAgent.match(/MicroMessenger/i) == "micromessenger";
      var qq = sUserAgent.match(/QQ/i) == "micromessenger";
      var isHuawei = sUserAgent.match(/huawei/i) == "huawei";
      var isHonor = sUserAgent.match(/honor/i) == "honor";
      var isOppo = sUserAgent.match(/oppo/i) == "oppo";
      var isOppoR15 = sUserAgent.match(/pcam00/i) == "pcam00";
      var isVivo = sUserAgent.match(/vivo/i) == "vivo";
      var isXiaomi = sUserAgent.match(/xiaomi/i) == "xiaomi";
      var isXiaomi2s = sUserAgent.match(/mix\s/i) == "mix ";
      var isRedmi = sUserAgent.match(/redmi/i) == "redmi";
      var isSamsung = sUserAgent.match(/sm-/i) == "sm-";
      if (isIphone) {
        window.location.href =
          "https://apps.apple.com/cn/app/%E5%BF%83%E5%8A%A830%E7%A7%92-%E8%AF%AD%E9%9F%B3%E8%81%8A%E5%A4%A9%E4%BA%A4%E5%8F%8B%E5%B9%B3%E5%8F%B0/id1568974512";
        return "iphone";
      } else if (vx || qq) {
        window.location.href =
          "https://static.psychexy.com/install/30s/30s_official_site.apk" +
          "?t=" +
          new Date().getTime();
        // alert("微信！");
        return "default";
      } else if (isHuawei || isHonor) {
        // window.location.href =
        //   "https://appgallery.huawei.com/#/app/C104575683?sharePrepath=ag&locale=zh_CN&source=appshare&subsource=C104575683&shareTo=weixin&shareFrom=appmarket";
        window.location.href = "appmarket://details?id=com.xinyue.xd30seconds";
        return "huawei";
      } else if (isOppo || isOppoR15) {
        window.location.href =
          "oppomarket://details?packagename=com.xinyue.xd30seconds";
        return "oppo";
      } else if (isVivo) {
        // window.location.href =
        //   "https://h5coml.vivo.com.cn/h5coml/appdetail_h5/browser_v2/index.html?appId=3297437&resource=301&source=7";
        window.location.href = "vivomarket://details?id=com.xinyue.xd30seconds";
        return "vivo";
      } else if (isXiaomi || isRedmi || isXiaomi2s) {
        window.location.href = "http://app.xiaomi.com/detail/1402133";
        // window.location.href = "mimarket://details?id=com.xinyue.xd30seconds";
        return "xiaomi";
      } else if (isSamsung) {
        window.location.href =
          "https://static.psychexy.com/install/30s/30s_official_site.apk";
        return "samsung";
      } else {
        window.location.href =
          "https://static.psychexy.com/install/30s/30s_official_site.apk" +
          "?v=" +
          new Date().getTime();
        return "default";
      }
    },
  },
  mounted() {
    //友盟Ulink
    // window.ULink([
    //   {
    //     id: "usr1mb1uacsl56gs",
    //     data: {
    //       test: "test11111111",
    //     },
    //     selector: "#btn",
    //     // auto: true,
    //     timeout: 2000,
    //     lazy: false,
    //     useOpenInBrowerTips: "default",
    //     // function (ctx) {
    //     //   //提示浏览器打开 带遮罩层demo
    //     //   return `<div style="position:fixed;left:0;top:0;background:rgba(255,0,255,0.5);width:100%;height:100%;z-index:19910324;"></div>`;
    //     // },
    //     proxyOpenDownload: function (defaultAction, LinkInstance) {
    //       console.log(defaultAction);
    //       if (LinkInstance.solution.type === "scheme") {
    //         // qq或者微信环境特殊处理下
    //         if (ULink.isWechat || ULink.isQQ) {
    //           // 在qq或者微信环境执行内置逻辑，具体内置逻辑为:当设置了useOpenInBrowerTips字段时，qq&&微信&&scheme时，启用蒙层提示去浏览器打开
    //           defaultAction();
    //         } else {
    //           window.location.href = LinkInstance.solution.downloadUrl;
    //         }
    //       } else if (LinkInstance.solution.type === "universalLink") {
    //       }
    //     },
    //   },
    // ]);
  },
};
</script>

<style lang="less" scoped>
.MarketJump {
  position: relative;
  height: 100%;
  .imgBg {
    width: 100%;
    height: 100%;
  }
  .shichang {
    display: flex;
    justify-content: space-around;
    align-items: center;
    position: absolute;
    padding: 10px 0px;
    bottom: 0px;
    height: 61px;
    width: 100%;
    background: rgba(0, 0, 0, 80%);
    .one {
      width: 50%;
      padding-left: 10px;
      .imgA {
        width: 100%;
      }
    }
    .two {
      width: 60%;
      display: flex;
      justify-content: flex-end;
      padding-right: 10px;
      #btn {
        width: 60%;
        height: 40%;
        display: inline-block;
        padding: 10px 13px;
        font-size: 20px;
        background-color: #cb4fff;
        border: 1px solid #cb4fff;
        border-radius: 25px;
        color: white;
        font-weight: 700;
      }
    }
  }
}
</style>